package com.wangnian.wangcai.dao;

import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.List;

/**
 * @author wangnian
 */
@Repository
public interface NameInfoDao extends JpaRepository<NameInfo, Serializable> {

    List<NameInfo> findByMonitorIsTrue(Sort zf);

    NameInfo findByCode(String code);

    @Query(value = "from NameInfo  where  mai=0 and allow=TRUE  order by zf")
    List<NameInfo> getRandomChaoDi();

    //获取大于涨幅的个数
    int countByZfGreaterThan(Double zf);

    //获取小于涨幅的个数
    int countByZfLessThan(Double zf);

    //获取所有的涨幅合计
    @Query(value = "select  sum(zf)/count(1) from NameInfo where monitor=TRUE")
    Double svgZf();


}